﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wozuji.Logic.Users;

public partial class u_passactivate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string code = "";
            try
            {
                code = Request.QueryString["code"].ToString();

            }
            catch (Exception ex)
            {
                code = "";
            }
            if (!code.Equals(""))
            {
                TextBox1.Text = code;
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //校验用户输入
        if (TextBox1.Text.Equals(""))
        {
            Label1.Text = "请输入认证码";
        }
        else if (TextBox2.Text.ToString().Equals("") || TextBox3.Text.ToString().Equals(""))
        {
            Label1.Text = "请输入您的新密码";
        }
        else if (!TextBox2.Text.ToString().Equals(TextBox3.Text.ToString()))
        {
            Label1.Text = "两次密码输入不一致" + TextBox2.Text.ToString() + "+" + TextBox3.Text.ToString();
        }
        else
        {

            //开始重置密码
            Users ur = new Users();
            if (ur.rescoverPassword(TextBox1.Text.ToString(), TextBox2.Text.ToString()))
            {
                Wozuji.Common.MessageBox.ShowAndRedirect(this.Page, "您的密码已经重置成功,请使用新密码登录！", "userlogin.aspx");
            }
            else
            {
                Label1.Text = "您的验证码不正确或已过期";
            }
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("/u/userregister.aspx");
    }
}